package com.szewec.ps.ui.road.facilities.intersection.task.utils;

import android.content.Context;

import com.szewec.ps.ui.road.facilities.intersection.task.templete.CheckDialog;
import com.szewec.ps.util.ListUtil;

import java.util.ArrayList;
import java.util.List;

public class RollUtils {
    /**
     * @param context
     * @param list        需要显示的清单
     * @param checkedList 选中的行
     * @param click       点击确定后的回调
     */
    public static void showCheck(Context context, List<?> list, List<?> checkedList, CheckDialog.OnViewClick click) {
        List<Object> tempList = new ArrayList<>();
        ListUtil.copyList(checkedList, tempList, Object.class);
        CheckDialog dialog = new CheckDialog(context).setMList(list).setTargetList(tempList);
        dialog.setOnClickBottomListener(new CheckDialog.OnClickBottomListener() {
            @Override
            public void onDetermineClick() {
                click.onClick(dialog.getTargetList());
                dialog.dismiss();
            }

            @Override
            public void onCancelClick() {
                dialog.dismiss();
            }
        });
        dialog.show();
    }
}
